import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// import 
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import TreeTable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor' // 调用富文本编辑器
import axios from 'axios'
import './assets/css/global.css'
// 富文本编辑器外部引用样式  三种样式三选一引入即可
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.bubble.css'
import VDistpicker from "v-distpicker";
Vue.config.productionTip = false
Vue.component('tree-table', TreeTable)
    //定义全局时间过滤器
Vue.filter('dataFilter', function(allDateList) {
    const dateList = new Date(allDateList);
    const y = dateList.getFullYear();
    const m = (dateList.getMonth() + 1 + '').padStart(2, '0');
    const d = (dateList.getDate() + '').padStart(2, '0');
    const hh = (dateList.getHours() + '').padStart(2, '0');
    const mm = (dateList.getMinutes() + '').padStart(2, '0');
    const ss = (dateList.getSeconds() + '').padStart(2, '0');

    // yyyy-mm-dd hh:mm:ss 替换成转换的内容
    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.use(ElementUI);
// 请求拦截器
axios.interceptors.request.use(
	config => {
		if (sessionStorage.getItem("token") != null&&
		sessionStorage.getItem("token") != undefined&&
		config.url.indexOf('/API/login') == -1
		// token如果存在并且不是登录接口，则统一在http请求的header都加上token，这样后台根据token判断你的登录情况，
		//在这里插一嘴axios的请求设置头name后台接收时必须也设置接收这个请求头name（一一对应）,否者会报415
		) {
			config.headers["token"] = localStorage.getItem("token");
		}
		return config;
	},
	err => Promise.reject(err)
);



Vue.use(VueQuillEditor);
new Vue({
    router,
    render: h => h(App)
}).$mount('#app')